package com.ruoyi.bussiness.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.MgtStarDriving;
import com.ruoyi.bussiness.service.IMgtStarDrivingService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 星级驾驶Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@Controller
@RequestMapping("/bussiness/driving")
public class MgtStarDrivingController extends BaseController
{
    private String prefix = "bussiness/driving";

    @Autowired
    private IMgtStarDrivingService mgtStarDrivingService;

    @RequiresPermissions("bussiness:driving:view")
    @GetMapping()
    public String driving()
    {
        return prefix + "/driving";
    }

    /**
     * 查询星级驾驶列表
     */
    @RequiresPermissions("bussiness:driving:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MgtStarDriving mgtStarDriving)
    {
        startPage();
        List<MgtStarDriving> list = mgtStarDrivingService.selectMgtStarDrivingList(mgtStarDriving);
        return getDataTable(list);
    }

    /**
     * 导出星级驾驶列表
     */
    @RequiresPermissions("bussiness:driving:export")
    @Log(title = "星级驾驶", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MgtStarDriving mgtStarDriving)
    {
        List<MgtStarDriving> list = mgtStarDrivingService.selectMgtStarDrivingList(mgtStarDriving);
        ExcelUtil<MgtStarDriving> util = new ExcelUtil<MgtStarDriving>(MgtStarDriving.class);
        return util.exportExcel(list, "星级驾驶数据");
    }

    /**
     * 新增星级驾驶
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存星级驾驶
     */
    @RequiresPermissions("bussiness:driving:add")
    @Log(title = "星级驾驶", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MgtStarDriving mgtStarDriving)
    {
        return toAjax(mgtStarDrivingService.insertMgtStarDriving(mgtStarDriving));
    }

    /**
     * 修改星级驾驶
     */
    @RequiresPermissions("bussiness:driving:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MgtStarDriving mgtStarDriving = mgtStarDrivingService.selectMgtStarDrivingById(id);
        mmap.put("mgtStarDriving", mgtStarDriving);
        return prefix + "/edit";
    }

    /**
     * 修改保存星级驾驶
     */
    @RequiresPermissions("bussiness:driving:edit")
    @Log(title = "星级驾驶", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MgtStarDriving mgtStarDriving)
    {
        return toAjax(mgtStarDrivingService.updateMgtStarDriving(mgtStarDriving));
    }

    /**
     * 删除星级驾驶
     */
    @RequiresPermissions("bussiness:driving:remove")
    @Log(title = "星级驾驶", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mgtStarDrivingService.deleteMgtStarDrivingByIds(ids));
    }
}
